<?php

namespace app\common\model;

use fast\Random;
use think\Model;


class Mycardlog extends Model
{

    

    

    // 表名
    protected $name = 'mycardlog';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'integer';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = false;
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
    ];
    


    /**
     * 生成核销码
     * */
    public function write_number($num=10){
        $write_number=Random::alnum($num);
        $log=$this->field("1")->where(["write_number"=>$write_number])->where("residue >0 ")->find();
        if(!empty($log)){
            $this->write_number($num);
        }
        return $write_number;
    }
}
